home *** CD-ROM | disk | FTP | other *** search
/ The Arsenal Files 8 / The Arsenal Files Collection #8 (Arsenal Computer) (1996).ISO / g_quake / mdledit.zip / MDL.TXT < prev    next >
Text File  |  1996-08-18  |  23KB  |  590 lines

  1. -----------------------------------------------------------------------------
  2. MedDLe v1.5
  3. -----------------------------------------------------------------------------
  4.  
  5.     by brian martin
  6.     brian@phyast.pitt.edu
  7.     http://www.phyast.pitt.edu/~brian
  8.     also look at http://www.phyast.pitt.edu/~brian/meddle
  9.  
  10.     Disclaimer: The author takes no responsiblity for misuse of
  11.     this program. He also is not responsible for any damage caused by it.
  12.  
  13.     This documentation needs work. period. it should be helpful though.
  14.  
  15. -----------------------------------------------------------------------------
  16. Quick Start:
  17. -----------------------------------------------------------------------------
  18.  
  19. edit mdl.cfg to fit your needs
  20. run mdl (i.e. "mdl player.mdl")
  21. hit key '1' for help
  22.  
  23. what's new??
  24.     fixed some bugs
  25.     script language
  26.     model generation
  27.     gif support
  28.     improved frame export/import functions
  29.     command line options slightly different
  30.  
  31. -----------------------------------------------------------------------------
  32. Contents:
  33. -----------------------------------------------------------------------------
  34.  
  35.         1. About MedDLe
  36.         2. Installation
  37.         3. Basic Use
  38.         4. Editing MDL files (step by step)
  39.              4.a Textures
  40.              4.b Frames
  41.         5. Script Language
  42.         6. Notes about file types
  43.         7. History
  44.  
  45. -----------------------------------------------------------------------------
  46. 1. About
  47. -----------------------------------------------------------------------------
  48.  
  49. MedDLe is a program which lets you look at and edit the mdl
  50. files in quake. These are the files which describe the objects
  51. in quake and are located in the QUAKE\PROGS directory. You have to first
  52. unpack the id1.pak file with a program like unpack or qube. These can both
  53. be found at ftp.cdrom.com.
  54.  
  55. Features :
  56.         View bitmaps (object textures)
  57.         View/edit point mapping of the vertices
  58.         Export model textures to a BMP or GIF file
  59.         Import BMP or GIF files to give objects a new 'skin'
  60.         Export animation frames to wrl,asc,dxf,pov,map, and raw files
  61.         Import RAW files to make new animations
  62.         Small script language which will allow you to totally screw an mdl
  63.         3D View of object (vertex / wireframe / flatshaded / texture mapped views)
  64.         Animation frame browser
  65.         Played color changer
  66.         .more.
  67.  
  68. -----------------------------------------------------------------------------
  69. 2. Installation
  70. -----------------------------------------------------------------------------
  71.  
  72. You should stick MedDLe in its own directory. Just unzip it
  73. in a suitable directory (i.e. c:\mdl).  You should have these files
  74. in the MedDLe directory:
  75.  
  76.     MDL.EXE         -the executable
  77.     MDL.CFG         -the configuration file
  78.     MDL.FNT         -the fonts
  79.     MDL.PAL         -the palette
  80.     MDL.MAP         -the colormap
  81.     KEY.TXT         -quick reference sheet
  82.         -MDLSRC.ZIP     -the source code- i will release separately or mail me
  83.     CWSDPMI.EXE     -dpmi environment (not needed if in windows)
  84.     EXAMPLE/        -directory with script example(s)
  85.  
  86. If everything is in place, bring up MDL.CFG in a text editor and set
  87. the path variable and video driver to match your system. You can set
  88. the video resolution here too. When your done, save the file. That's it!
  89.  
  90. note: You may need a 386/483sx and math co-procesor or a 486dx or higher
  91. to run this. I don't know. There are several math emulators on the net
  92. if it doesn't work on your numerically challenged machine.
  93.  
  94. -----------------------------------------------------------------------------
  95. 3. Basic Use
  96. -----------------------------------------------------------------------------
  97.  
  98. MedDLe has no GUI at this point. Live with it. :)
  99.  
  100. MedDLe can both be used to view and edit mdl files. To
  101. start the program just type 'mdl file.mdl' where 'file.mdl'
  102. is a valid mdl filename.
  103.  
  104. You start in 3D mode.
  105.  
  106.          ARROW up/down : move eye position up/down
  107.          ARROW left/right : previous/next animation frame
  108.  
  109.          Esc :        exit
  110.          2 :            goto 2d mode
  111.          1 :            goto help (about)
  112.          t :            draw triangles
  113.          v :            draw vertices
  114.          s :            TAKE SCREEN SHOT (saved as pic#.bmp)
  115.          h :            show header
  116.          c :            auto cycle through animation frames
  117.          b :            change background color (black, gray, white)
  118.          r :             reset view
  119.          . or > :     next skin
  120.          , or < :        previous skin
  121.          " or ' :        next pants color
  122.          ; or : :        previous pants color
  123.          } or ] :     next shirt color
  124.          { or [ :        previous shirt color
  125.          Tab :        change rendering mode
  126.                     (flat shade, gourourd shade, texture, texture + shade)
  127.  
  128.          MOUSE up/down + right button : zoom in/out
  129.          MOUSE move + left button : rotate model
  130.          MOUSE move : move light source
  131.  
  132.  
  133. Just think of the mouse as your hand grabbing the object. It should
  134. then be easy to control. If you hit the '2' key, you will go to
  135. 2D mode. Here the keys are:
  136.  
  137.  
  138.          ARROW Keys:     move cursor
  139.  
  140.          Esc :        exit
  141.          3 :            goto 3d mode
  142.          1 :            goto help (about)
  143.          t :            draw triangles
  144.          v :            draw vertices
  145.          s :            SAVE MDL FILE
  146.          p :
  147.          m :
  148.          . or > :     next skin
  149.          , or < :        previous skin
  150.          " or ' :        next pants color
  151.          ; or : :        previous pants color
  152.          } or ] :     next shirt color
  153.          { or [ :        previous shirt color
  154.  
  155.          MOUSE move : move cursor
  156.          MOUSE left button: grab hi-lighted vertex
  157.  
  158.  
  159. The mouse can be used to move vertices in this mode.
  160.  
  161. ** NEW **
  162. Command line options of importance.. Now meddle figures out if it's
  163. a skin or frame by the extension.
  164.  
  165.         import gif (or bmp) to skin number # in model.mdl
  166.         (if # is greater than model skins, skin is added)
  167.  
  168.             mdl -i pic.gif # model.mdl
  169.  
  170.  
  171.         export skin number # to gif (or bmp) from model.mdl
  172.         (if # is 0 or  negetive, a new blank skin with triangles is exported)
  173.  
  174.             mdl -e pic.gif # model.mdl
  175.  
  176.         import raw to frame number # in model.mdl
  177.  
  178.             mdl -i frame.raw # model.mdl
  179.  
  180.  
  181.         export frame number # to asc from model.mdl
  182.  
  183.             mdl -e frame.asc # model.mdl
  184.  
  185.         run a script file (must have a .med extension)
  186.  
  187.             mdl script.med
  188.  
  189.  
  190. !IMPORTANT!
  191. NOTE: When you use MedDLe, it will read the original mdl files from
  192. the path you set BUT will do all saving and reading from the
  193. current directory. If you load MedDLe in your quake/progs directory,
  194. you may end up erasing something you wish you hadn't. Of course you
  195. can change the read directory in the cfg file, but the save directory
  196. is always the current one.
  197. It may be a hassel, but you'll have to copy the saved mdl to the progs
  198. directory for quake to see the changes (duh).
  199.  
  200. -----------------------------------------------------------------------------
  201. 4. Editing MDL files
  202. -----------------------------------------------------------------------------
  203.  
  204. I have some info at http://www.phyast.pitt.edu/~brian/meddle but this
  205. ought to help you get started.
  206.  
  207. 4.a Textures
  208.  
  209.     The following explains the basic proceedure for adding a new skin to
  210.     the player model.
  211.  
  212.     In this example the 'player.mdl' file is modified with the texture
  213.     'play1.bmp'.
  214.  
  215.     1. First export the original texture. It will be saved in your
  216.     MedDLe directory.
  217.     'mdl -e play0.bmp 1 player.mdl'
  218.     NOTE: If you want to start from stratch (blank skin), use
  219.     'mdl -e play0.bmp 0 player.mdl'
  220.  
  221.     2. Now go off and modify the texture in your favorite paint
  222.     program. Make sure you save the new skin with 8-bit color
  223.     in GIF or BMP format. Save the modified texture as 'play1.bmp'
  224.     and place it in your MedDLe directory. The file mdl.pal (included)
  225.     can be loaded into programs like Paint Shop Pro so you can use the
  226.     correct palette, but MedDLe will try to match it up with the quake
  227.     palette if you don't. MedDLe also resizes the picture if necessary.
  228.  
  229.     3. Import the new texture (play1.bmp).
  230.     'mdl -i play1.bmp 2 player.mdl'
  231.     Since we said '2' it will add the skin in addition to the original
  232.     skin.
  233.  
  234.     4. Get into 2D mode (hit '2'). You can use the mouse to tweak some
  235.     of the vertices. You want to make sure that you don't change the
  236.     original layout too much, but also want to make sure there is no
  237.     background showing through any of the polygons. You should toggle back
  238.     and forth between 2D mode and 3D mode to check that the texture mapping
  239.     is ok. When your done tweaking, PRESS 's' IN 2D MODE to save your changes.
  240.  
  241.     Also, you can now change the shirt and pants color to see if you used
  242.     some colors you shouldn't have. Use the " [ ] ; ' " keys to do this.
  243.  
  244.     NOTE: If you don't press 's' in 2D mode your imported texture
  245.     will NOT be saved!
  246.  
  247.     5. Copy the new 'player.mdl' file to the quake/progs directory.
  248.     You may want to back up the original 'player.mdl' before doing this.
  249.  
  250.     6. Run QUAKE!
  251.  
  252.     Of course the player.mdl is you, so you won't see your changes... :)
  253.  
  254. ** NEW **
  255. 4.a Textures
  256.  
  257.     The following explains the basic proceedure for replacing animation
  258.     frames. In this example the 'player.mdl' file is modified with the
  259.     3d data file 'play1.raw'.
  260.  
  261.     1. First export the original frame. It will be saved in your
  262.     MedDLe directory.
  263.     'mdl -e play0.raw 1 player.mdl'
  264.     MedDLe will figure out the type of file it is by the extension. So
  265.     'mdl -e play0.asc 1 player.mdl'
  266.     will save it as a 3d studio asc file. Exportable file types are
  267.     pov (POVRay), dxf (cadd type), raw (raw points), asc (ascii),
  268.     map (quake map), wrl (vrml file) and 3ds (3dstudio file).
  269.     The wrl file is the most complete. If you export the skin and convert
  270.     it to a GIF file named 'skin.gif', the wrl file will be texture mapped.
  271.     The 3ds file isn't quite working perfect so use asc if you have 3d studio.
  272.     The raw file can be read by the 3d editor called Breeze Designer which
  273.     is a shareware program (or freeware?) which allows vertex editing. I like
  274.     it and recommend it.
  275.  
  276.     Remember, to see the frame number of the frames, hit 'h' while in 3d mode.
  277.     Use that number when extracting frames.
  278.  
  279.     2. Now go off and modify the frame data in your favorite program.
  280.     (like i said, Breeze Designer is nice) Save the modified frame as
  281.     'play1.raw' and place it in your MedDLe directory.
  282.  
  283.     One word about 3d editing. DON'T CHANGE THE NUMBER OF POINTS IN A FRAME
  284.     IF YOU PLAN ON IMPORTING TO AN EXISTING MDL FILE! JUST MOVE POINTS.
  285.     DON'T ADD OR DELETE POINTS! Making a model from scratch is a different
  286.     story. Read mdl script section below for that.
  287.  
  288.     3. Import the new frame (play1.raw).
  289.     'mdl -i play1.raw 1 player.mdl'
  290.  
  291.     4. Get into 2D mode (hit '2'). PRESS 's' IN 2D MODE to save your changes.
  292.  
  293.  
  294.     NOTE: If you don't press 's' in 2D mode your new frame won't be saved!
  295.  
  296.     5. Copy the new 'player.mdl' file to the quake/progs directory.
  297.     You may want to back up the original 'player.mdl' before doing this.
  298.  
  299.     6. Run QUAKE!
  300.  
  301.  
  302. Some added features that a serious editor will use are..
  303.  
  304.     - the file mdl.pal is used for quake. If you are editing a custom game,
  305.         you can replace mdl.pal with your own palette. The colormap can also
  306.         be changed (mdl.map).
  307.     - if you want to add a skin, just make sure the number is greater that
  308.         the current number of skins (same for frames)
  309.     - if you want to extract a blank skin is a number equal to or less
  310.         than zero.
  311.  
  312. -----------------------------------------------------------------------------
  313. 5. Scripting Language
  314. -----------------------------------------------------------------------------
  315.  
  316.     There is a small, but powerful scripting language. It is easy to
  317.     use and is the only way to really do serious work. Hopefully
  318.     there are some examples with this distribution.
  319.  
  320.     The script isn't high tech, so you must use proper syntax. That is,
  321.     you better have a space between words and suff.
  322.  
  323.     -Anything after a # is ignored.
  324.     -the progspath in the cfg file is NOT used.
  325.     -all script files must have extension .med
  326.     -type "mdl <name>.med" to run the script
  327.  
  328.     Here are th commands followed by a description. Things in <> are
  329.     necessary arguments:
  330.  
  331.     path <workingpath>
  332.  
  333.         this sets the working path <workingpath> for following file io.
  334.         you should end the path with a slash or back-slash (like oj).
  335.  
  336.     load_mdl <name>
  337.  
  338.         this will load <name> into MedDLe. You need to load a file
  339.         before you can change things.
  340.  
  341.     save_mdl <name>
  342.  
  343.         this saves the current (modified) mdl file to <name>
  344.  
  345.     new_mdl <frame.name>
  346.  
  347.         this creates a brand spanking new mdl file. You must supply
  348.         a base frame. A blank skin will be created. Note that the base
  349.         frame usually is not ever going to be used for the model, but
  350.         serves as a template for all of the other frames. The frame is
  351.         stored in the first frame slot.
  352.  
  353.     get_info <name>
  354.  
  355.         this outputs some of the model info to a file <name>.
  356.  
  357.     decompose <medfile> <skin extension> <frame extension>
  358.  
  359.         this extracts all skins and frames from a model. you must specify
  360.         the file extensions for the extracted data (i.e. gif or bmp for
  361.         <skin extension>). You must also give a med file name which will
  362.         be created to help put things back together. To use the created
  363.         file, make sure to un-comment out the 'save' line at the end of
  364.         the file.
  365.  
  366.     add <filename>
  367.  
  368.         adds <filename> to the current loaded model
  369.  
  370.     insert <filename> <index>
  371.  
  372.         inserts <filename> to the current loaded model in position <index>
  373.  
  374.     extract <filename> <index>
  375.  
  376.         extracts frame or skin number <index> to <filename>
  377.  
  378.     set <data_type> <value>
  379.  
  380.         sets certain header values in the model. the valid data types are:
  381.         (these are floating point values)
  382.             xscale, yscale, zscale, xoffset, yoffset, zoffset
  383.             eyex, eyey, eyez
  384.             average_size, radius
  385.         (these are unsigned integer values)
  386.             version, num_skins, num_frames, num_vertices,
  387.             skin_width, skin_height, sync_type, flags
  388.         if you don't know what your doing you can really screw things up here.
  389.         this only sets the value, it doesn't modify the data, so changing the
  390.         skin width will most likely just crash quake (and meddle) when you
  391.         try loading a file.
  392.  
  393.     frame_name <index> <new name>
  394.  
  395.         this changes the frame <index>'s name to <new name>. Remember that
  396.         with MedDLe all indices start at 1 (not 0).
  397.  
  398.     (I know I need to add a delete feature as well)
  399.     Here are some examples:
  400.  
  401.     example 1:
  402.  
  403.          path c:\quake\progs\    #set path to progs directory
  404.          load_mdl armor.mdl      #load armor model into memory
  405.          path c:\mdl\script\     #set path to script directory
  406.          decompose armor.med gif raw  #extract all of model into script dir
  407.                                                          #save skins in gif format and frames in raw format
  408.                                                          #create a file armor.med which will put the model
  409.                                                          #back together
  410.     example 2:
  411.          path c:\quake\progs\    #set path to progs directory
  412.          load_mdl player.mdl     #load player model into memory
  413.          path c:\pictures\       #set path to pictures directory
  414.          add newskin.bmp         #adds a new skin
  415.          set zscale .1           #squash the model (why? who knows..)
  416.          path c:\quake\progs\    #set path to progs directory
  417.          save_mdl player2.mdl    #save changes to player2.mdl in progs dir
  418.  
  419.     example 3:
  420.          path c:\quake\progs\    #set path to progs directory
  421.          load_mdl player.mdl     #load player model into memory
  422.          path c:\mdl\            #set path to mdl
  423.          extract frame1.raw 71   #extract frame 71 to frame1.raw in mdl dir
  424.          new_mdl frame1.raw      #generate a new model
  425.          extract skin1.gif 1     #get the blank skin (so we can modify it)
  426.          save_mdl newplay.mdl    #save the new model
  427.  
  428.     Hope this helps out.
  429.     I should mention that ripping appart existing mdl files with decompose
  430.     and rebuilding them will not produce the original models. Why? you ask.
  431.     Well as I mentioned earlier, a base frame is used to generate the
  432.     texture and mapping. If you just use the first frame of the model,
  433.     you may get crappy results. For instance, the ogre.mdl has a chain
  434.     saw which won't generate a nice mdl. So what do you do? I think this
  435.     is what id did: You create your objects (ogre and chainsaw) separately
  436.     and then place them in the model file such that they are facing in
  437.     the x direction and are fairly symmetric about the y axis. (z points up).
  438.     Then generate a model with that frame. You can then move the chain saw to
  439.     the hand of the ogre in the other frames. So the script may look like:
  440.  
  441.         new_mdl base.raw
  442.         insert frame1.raw
  443.  
  444.     instead of just:
  445.  
  446.         new_mdl frame2.raw
  447.  
  448.     Now you may still have some problem getting the texture map to show
  449.     all sides of the chainsaw (or any square object for that matter). In
  450.     this case you should rotate the object around it's y axis 45 degrees
  451.     in the base frame. This will expose the sides of object better in
  452.     some cases. Because of all these little tricks, you can't just
  453.     expect to make the player.mdl from decompose. (you'll have to move
  454.     things so that the gun, axe, and fire flash generate a nice base skin).
  455.  
  456.     If you make a model from scratch, you should keep in mind that
  457.     your probably using a PC, not a CRAY. KISS. Keep It Simple Stupid.
  458.     Between 1 and 500 triangles is good. Also remember that the models
  459.     only have a resolution of 255x255x255 in discrete units, but are scaled.
  460.     The typical height of a model (in your editors coordinates) is
  461.     about 70. and monsters like the ogre is over 100. Models face in the
  462.     x direction, z is up, and y to the models left. They should be centered
  463.     about the origin, but this can be changed later using the 'set'
  464.     command. Also try to keep all the frame sizes about the same. You'll
  465.     find out that if you make the base frame too different, things will
  466.     be screwed.
  467.     Is that good enough for now?
  468.  
  469.     One last note. Because MedDLe wasn't written with speed in mind
  470.     when it comes to import/extract, things get slower and slower the
  471.     more frames you add. It should't crash though.
  472.         I take that back. Another note: you may want to pipe the out put
  473.         from the script to a file : "mdl script.med > out.txt"
  474.  
  475. -----------------------------------------------------------------------------
  476. 6. Notes about file types
  477. -----------------------------------------------------------------------------
  478.  
  479.     Since there is a lot of file importing and exporting going on,
  480.     I decided to say say a little about each file type.
  481.  
  482.     For the pictures, there is not much to say except to keep
  483.     the colors to 8-bit (256 color). GIF and BMP are supported
  484.     and are color matched and resized when imported.
  485.  
  486.     Now the 3d files. Since it seems like every editor interperates
  487.     the 3d coordinates differently...
  488.  
  489.         RAW: this file is just ascii numbers. the first 3 are the x,y,z
  490.         coordinates of the first vertex in the first triangle. The next 3
  491.         are the second vertex of the first triangle. The third set of 3
  492.         are the last vertex. The vertices are arranged such that the
  493.         surface normal points out (counter clockwise). (or maybe it points
  494.         in, can't remember.. just don't change the order). You can use a text
  495.         editor to create models with this format.
  496.  
  497.         ASC: this is a text format saved by 3d Studio. The coordinate
  498.         system in 3d studio is a bit different from quake. In quake,
  499.         z points up, in 3ds it points towards you. I fixed MedDLe such that
  500.         if you export an asc file, 3d Studio will display it properly,
  501.         but the coordinates are different. (so to convert an exported RAW
  502.         to an ASC and then import may screw things). By properly, I mean
  503.                 the 'front' view is the front, the 'left' is the left, etc...
  504.         Importing an asc file works the same. The front remains the front,
  505.         but the x y z values are changed around behind your back. You can
  506.         also create this file by hand. I just want to warn you that here the
  507.         vertices are stored in opposite order from the raw file.
  508.  
  509.         Those two formats allow import/export of frames and model generation.
  510.         The other formats are just export for now. I haven't had a chance to
  511.         really test them, but the WRL works nicely. Again I had to change
  512.         the coordinate system to get things to look ok, but don't worry
  513.         about it for now. The export of the quake MAP format is a little
  514.         different. This is because it exports the model in the raw byte
  515.         format, that is, each x,y,z value ranges from 0 to 255. I did this
  516.         because I didn't see a quake map editor taking any negative values.
  517.         When a really good map editor is out, I'll fix the import function
  518.         for this. The other file types are DXF and POV. Which I haven't
  519.         had a chance to test.
  520.  
  521. -----------------------------------------------------------------------------
  522. 7. History
  523. -----------------------------------------------------------------------------
  524.  
  525. v1.5
  526.     -3d export added and some import
  527.     -script language
  528.     -gif support
  529. v1.4
  530.     -fixed import/export- now its rocks
  531.     -shirt/pants color changing
  532.     -multi skins handled better
  533.     -saving enabled
  534.     -some new key mappings
  535. v1.3
  536.     -includes source with public release
  537.     -gouraud shading with colormap
  538.     -new file format support
  539.     -help screens
  540.     -more comments in source and some cleaning
  541. v1.2
  542.     -released with source
  543.     -better mouse control
  544. v1.1
  545.     -not released-gui experiments
  546.     -gouraud shading
  547. v1.0
  548.     -now you can edit the 2d vertices
  549.     -fixed bugs which caused crashes in 3d mode
  550.     -expanded video support via GRX20
  551.     -added flat shading to 3d models and texture mapping
  552.     -you can now cycle through the frames of animation
  553.     -several other little things
  554. v0.1
  555.     -added wire frame 3d view
  556.     -added importing/exporting BMP files
  557. v0.00002
  558.     - same as v0.00001 but with correct palette
  559. v0.00001 (not released, except on IRC)
  560.     - displayed the skin texture
  561.  
  562. Wish list..
  563.  
  564.     -stick man... you'll see
  565.     -gui
  566.     -more time
  567.  
  568. ------------------------------------------------------------------------------
  569.  
  570. Programmers Note: in this version GRX20 was used along with 3DGPL.
  571. I sorta merged the two together and stuck some of my own stuff in there.
  572. The program is not optimized at all, and a sharp eye will notice that
  573. there is no _perspective_ texture mapping. Oh well, maybe I'll get around
  574. to that in a later version. Or maybe not.
  575.  
  576. Special thanks goes out to...
  577.  
  578. Gershon Elber for the source to gif-lib (which I completely trashed)
  579. John Carmack for release of utility source
  580. Chris Babcock for making me aware of the frame data
  581. Raphael Quinet and Sean Werkema for giving out their source which
  582.     made learning to read BMP files easy (also the source taught me a few tricks)
  583. Sergei Savchenko for 3DGPL. I learned a lot of 3D programming from that and
  584.     use several modified versions of his routines for clipping and texture mapping.
  585. DJGPP v2 and the excellent GRX20 graphics lib.
  586. Id for quake.
  587. Becky for putting up with me :)
  588.  
  589. -end document------------------------------------------------------------------
  590.